﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.FileSaveBinaryInformation", ValueObject=true, ServerTypeId="{c3de0784-43e6-4f12-bd0c-f0d9a34ebf93}")]
    public sealed class FileSaveBinaryInformation : ClientValueObject
    {
        private bool m_checkRequiredFields;
        private byte[] m_content;
        private string m_eTag;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            string str = peekedName;
            if (str != null)
            {
                if (!(str == "Content"))
                {
                    if (str == "ETag")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_eTag = reader.ReadString();
                        return flag;
                    }
                    if (str == "CheckRequiredFields")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_checkRequiredFields = reader.ReadBoolean();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.m_content = reader.ReadByteArray();
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Content");
            DataConvert.WriteValueToXmlElement(writer, this.Content, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "ETag");
            DataConvert.WriteValueToXmlElement(writer, this.ETag, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "CheckRequiredFields");
            DataConvert.WriteValueToXmlElement(writer, this.CheckRequiredFields, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public bool CheckRequiredFields
        {
            get
            {
                return this.m_checkRequiredFields;
            }
            set
            {
                this.m_checkRequiredFields = value;
            }
        }

        [Remote]
        public byte[] Content
        {
            get
            {
                return this.m_content;
            }
            set
            {
                this.m_content = value;
            }
        }

        [Remote]
        public string ETag
        {
            get
            {
                return this.m_eTag;
            }
            set
            {
                this.m_eTag = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{c3de0784-43e6-4f12-bd0c-f0d9a34ebf93}";
            }
        }
    }
}

